package cn.lili.modules.payment.kit.plugin.alipay;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class AlipayConfig {

    @Value("${ali.app_id}")
    private String APP_ID;
    @Value("${ali.merchant_private_key}")
    private String PRIVATE_KEY;
    @Value("${ali.alipay_public_key}")
    private String PUBLIC_KEY;

    private final String GATEWAY_URL = "https://openapi.alipay.com/gateway.do";

    private final String ENCRYPT_TYPE = "AES";

    private final String SIGN_TYPE = "RSA2";

    private final String CHARSET = "utf-8";

    private final String FORMAT = "json";

    public AlipayClient getAlipayClient() {
        return new DefaultAlipayClient(
                GATEWAY_URL,
                APP_ID,
                PRIVATE_KEY,
                FORMAT,
                CHARSET,
                PUBLIC_KEY,
                SIGN_TYPE
        );
    }
}
